package w.k.w.zhedielan;

import android.content.Intent;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import flyn.Eyes;

public class MainActivity extends AppCompatActivity {
    CollapsingToolbarLayout cLayout;
    AppBarLayout appBarLayout;
    FloatingActionButton fab;
    Toolbar toolbar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        cLayout = findViewById(R.id.c);
        appBarLayout = findViewById(R.id.app_bar);
        fab = findViewById(R.id.fab);
        toolbar = findViewById(R.id.toolbar);
        cLayout.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
            Log.e("eeeee","left->"+left+",top->"+top+",right->"+right+",bottom->"+bottom+",oldLeft->"+oldLeft+",oldTop->"+oldTop+",oldRight->"+oldRight+"oldBottom->"+oldBottom);
        });
        appBarLayout.addOnOffsetChangedListener((appBarLayout1, verticalOffset) -> {
            Log.e("eeeee","verticalOffset->"+verticalOffset);
            if(verticalOffset==0){
                fab.hide();
            }else{
                fab.show();
            }
        });
        fab.setOnClickListener(v-> startActivity(new Intent(MainActivity.this,ScrollingActivity.class)));
        Eyes.setStatusBarColorForCollapsingToolbar(this,appBarLayout,cLayout,toolbar, ContextCompat.getColor(this,R.color.colorPrimary));
    }
}
